#include "net.h"

#include <iostream>

namespace app {
namespace net {


const long long Message::id() {
	return 1;
}
std::string Message::toString() const {
	return "id:1";
}

int DBObserver::update(helper::util::Event * event) {
	Message * message = static_cast<Message*>(event);
	if(message != nullptr){
		// get (k, v)
		// get type -> dispatch Table 
		// table.insert_or_update();
		std::cout << "Message:" << message->toString() << std::endl;
		return 0;
	}
	return -1;
}

int MockNet::recv() {
	Message msg;
	return visit([&msg](const std::string & key, helper::util::IPushObserver * o){
			std::cout << key << " ";
			if( o != nullptr)
				return o->update(&msg);
			else 
				return -1;
	});
}

}// namespace net
}// namespace app 
